package cn.edu.ctbu.datajpa01.webapi;

import cn.edu.ctbu.datajpa01.core.RUtils;
import cn.edu.ctbu.datajpa01.domain.Student;
import cn.edu.ctbu.datajpa01.domain.Teacher;
import cn.edu.ctbu.datajpa01.service.StudentService;
import cn.edu.ctbu.datajpa01.service.impl.StudentImplService;
import cn.edu.ctbu.datajpa01.service.impl.TeacherServiceImpl;
import cn.edu.ctbu.datajpa01.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/webapi/login")


public class LoginApiController {

    @Autowired
    private StudentImplService studentService;
    //   StudentService studentService;
    @GetMapping ("/student/list")
    public R student(String name, String password)throws Exception{
        Student student=studentService.findByNameAndPassword(name,password);

        return RUtils.success(student);
    }
    @Autowired
    private TeacherServiceImpl teacherService;

    @GetMapping ("/starter/teacher")
    public R teacher(String name, String password)throws Exception{
        Teacher teacher=teacherService.findByNameAndPassword(name,password);

        return RUtils.success(teacher);
    }
}
